package Search2017;

/**
 * 顺序查找
 * Created by 雷文康 on 2017/12/27.
 */
public class SequentialSearch {
    public static void main(String[] args) {
        int[] array={1,2,7,5,8,13,-5};
        System.out.println(sequentialSearch(array,13));
    }
    public static int sequentialSearch(int[] array, int num) {
        if (array == null || array.length == 0) {
            return  -1;
        }
        int i;
        for(i = 0 ; i < array.length; i++){
            if (array[i] == num) {
                return i;
            }
        }
        return -1;
    }
}
